<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-form-item label="转账人" prop="fromUser">
        <el-input
          v-model="queryParams.fromUser"
          placeholder="请输入昵称/拓聊号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="接受人" prop="toUser">
        <el-input
          v-model="queryParams.toUser"
          placeholder="请输入昵称/拓聊号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择" clearable  size="small">
          <el-option
            v-for="dict in transStatusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table  v-loading="loading" :data="list">
      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="转账人拓聊号" align="center" prop="cloudId" />
      <el-table-column label="转账人昵称" align="center" prop="nickName" />
      <el-table-column label="金额" align="center" prop="money" />
      <el-table-column label="接受人拓聊号" align="center" prop="toCloudId" />
      <el-table-column label="接受人昵称" align="center" prop="toNickName" />
      <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip/>
      <el-table-column label="状态" align="center" prop="vipStatus" :formatter="transStatusFormat" />
      <el-table-column label="转账时间" align="center" prop="createTime" />
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>

</template>

<script>
import { listTransferStream } from "@/api/model/stream";

export default {
  name: "transfer",
  data(){
    return {
      // 遮罩层
      loading: true,
      total: 0,
      list: [],
      //转账状态
      transStatusOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    }
  },
  created() {
    this.getList();
    this.getDicts("trans_status").then(response => {
      this.transStatusOptions = response.data;
    });
  },
  methods: {
    getList() {
      this.loading = true;
      listTransferStream(this.queryParams).then(response => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 状态
    transStatusFormat(row, column) {
      return this.selectDictLabel(this.transStatusOptions, row.status);
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
}
</script>
